﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Libero.FusionCharts;

namespace WebApplication1
{
    public partial class exemplo_SS_Manual : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // Create a chart
            Column3DChart oChart = new Column3DChart();

            // Set properties
            oChart.Background.BgColor = "ffffff";
            oChart.Canvas3D.CanvasBgColor = "eeeeee";
            oChart.ChartTitles.Caption = "Top seller";
            oChart.ChartTitles.SubCaption = "November";

            // Set a template
            oChart.Template = new Libero.FusionCharts.Template.OfficeTemplate();

            // Set data
            foreach (Sales s in GetSales())
            {
                oChart.Set.Add(new SSSetElement { Name = s.SalesmanName, Value = s.TotalSold, ShowName = true });
            }

            // Add trend lines
            oChart.TrendLines.Add(new TrendLineElement { StartValue = 530, EndValue = 533, Color = "33dd33", DisplayValue = "Very good" }
            );
            oChart.TrendLines.Add(new TrendLineElement { StartValue = 200, EndValue = 203, Color = "dd3333", DisplayValue = "Very bad" }
            );

            // Link the WebControl and the Chart
            chtTopSalles.ShowChart(oChart);
        }

        private List<Sales> GetSales()
        {
            List<Sales> s = new List<Sales>();

            s.Add(new Sales { SalesmanName = "Alan", TotalSold = 220m });
            s.Add(new Sales { SalesmanName = "Tom", TotalSold = 373m });
            s.Add(new Sales { SalesmanName = "Tete", TotalSold = 150m });
            s.Add(new Sales { SalesmanName = "Ana", TotalSold = 523m });

            return s;
        }
        private class Sales
        {
            public string SalesmanName;
            public decimal TotalSold;
        }
    }

}